<template>
    <div class="shop_info">
        <div class="base_header">
            <img @click="goBack()" class="back" src="../../assets/img/back.png" alt="">店铺简介
        </div>
        <div class="shop_header">
             <img src="../../assets/img/user/test-head.png" alt="" v-if="shopId==21">
            <img :src="imageDomain+shopInfo.logo" alt="" v-else>
            <div>
                <p>{{shopInfo.shopName}}</p>
                <p><img src="../../assets/img/shop/shop_star.png" alt="" v-for="star in shopInfo.level"></p>
            </div>
            <!--<span class="care">已关注</span>-->
        </div>
        <div class="item_info border">
             描述相符  <span class="blue">{{shopRate.descScore}}分</span>
        </div>
        <div class="item_info border">
            服务态度  <span class="blue">{{shopRate.serveScore}}分</span>
        </div>
        <div class="item_info mb10">
            物流服务  <span class="blue">{{shopRate.expressScore}}分</span>
        </div>
        <div class="item_info border">
            商家电话  <span>{{shopInfo.tel}}</span>
        </div>
        <div class="item_info mb10">
            商家邮箱  <span>{{shopInfo.email}}</span>
        </div>
        <div class="item_info border">
            所在地区  <span>{{shopInfo.province}}{{shopInfo.city}}{{shopInfo.region}}{{shopInfo.address}}</span>
        </div>
        <div @click="goAptitude(shopInfo.aptitudes)" class="item_info">
            证件信息  <span>商家资质</span>
        </div>
    </div>
</template>

<style>
    @import url("./shop_info.css");
</style>
<script>
    import {Toast} from 'mint-ui';
    import API from '../../assets/js/API'
    import Layer from '../../assets/js/MessageBox'
    export default{
        data(){
            return{
                shopId: this.$route.query.shopId,
                shopInfo:{},
                imageDomain: "",
                shopRate:{},
            }
        },
        created (){
             window.scrollTo(0,0);
            let url = API.serviceDomain + API.shopDetail+"/"+this.shopId;
            this.$http.get(url).then(
                (res) => {
                    if (res.body.status == '000000') {
                        this.shopInfo = res.body.data;
                        if(this.shopInfo != null && this.shopInfo.introduceScore == null){
                            this.shopInfo.introduceScore = 4.7;
                        }
                        if(this.shopInfo != null && this.shopInfo.serviceScore == null){
                            this.shopInfo.serviceScore = 4.5;
                        }
                        if(this.shopInfo != null && this.shopInfo.logisticsScore == null){
                            this.shopInfo.logisticsScore = 4.9;
                        }
                    } else {
                        Layer.showMsg(res.body.message);
                    }
                },
                (error) => {
                    Layer.showMsg("服务器开小差了...")
                    return
                }
            )
        },
        mounted(){
            this.imageDomain = API.imageDomain;
            this.getShopRate()
        },
        methods:{
            goBack(){
                this.$router.goBack()
            },
               getShopRate(){
                let url=API.evaluate+API.evaluateShopRate
                let form=new FormData();
                form.append('shopId',this.shopId)
                this.$http.post(url,form,{
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'}
                }).then(
                    (res)=>{
                        if(res.body.code==1){
                            this.shopRate=res.body.data
                        }else{
                             Layer.showMsg(res.body.error)
                        }
                       
                    },(err)=>{
                         Layer.showMsg("服务器开小差了...")
                            return
                    }
                )
            },
            goAptitude(aptitudes){
                if(aptitudes == null){
                    Layer.showMsg("商家还未上传资质.")
                    return
                }
                this.$router.push({path:'/aptitude',query:{'aptitueds':aptitudes}})
            }
        }
    }
</script>
